package com.ruoqing.auth.service.impl;

import com.ruoqing.redis.vo.BaseResponse;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;

/**
	* @author YaoXian
	* @title: TokenServiceImpl
	* @projectName ruoxi-blog
	* @description: 若兮微服务 - RPC远程调用业务层实现类
	* @date 2021-01-07 16:33
	*/
@Service
public class TokenServiceImpl {
		
		@Resource
		private TokenStore tokenStore;
		
		public BaseResponse removeToken(String token) {
				OAuth2AccessToken oAuth2AccessToken = tokenStore.readAccessToken(token);
				if (StringUtils.isEmpty(oAuth2AccessToken)){
						return BaseResponse.buildResponse("error","登录信息已失效!");
				}
				tokenStore.removeAccessToken(oAuth2AccessToken);
				return BaseResponse.buildResponse("ok","注销成功!");
		}
		
}
